unit slSQL;

interface

const BUFFER_LENGTH = 256;

procedure slClose();
function  slConnect(Server: string; Port: Integer; ModChars: string): Integer; overload;
function  slConnect(Server: string; Port: Integer; ModChars: string; var OutData: string): Integer; overload;
procedure slDisconnect();
function  slF(ColumnNumber: Integer; SetNumber: Integer = 0): string;
function  slFX(ColumnNumber: Integer; ModChars: string = 'E0'; SetNumber: Integer = 0): string;
function  slFN(ColumnName: string; SetNumber: Integer = 0): string;
function  slFNX(ColumnName: string; ModChars: string = 'E0'; SetNumber: Integer = 0): string;
function  slGetColumnCount(SetNumber: Integer = 0): Integer;
function  slGetColumnName(ColumnNumber: Integer; SetNumber: Integer = 0): string;
function  slGetError(): string;
function  slGetRow(SetNumber: Integer = 0; ModChars: string = 'E0'): Integer;
function  slOpen(FileName: string; ModChars: string = 'E0'): Integer;
function  slSel(Statement: string; SetNumber: Integer = 0; ModChars: string = 'E0'): Integer;

implementation

uses libslsql;

procedure slClose();
begin
  sluClose;
end;

function slConnect(Server: string; Port: Integer; ModChars: string): Integer;
var
  Size: Integer;
begin
  Size := 0;
  Result := sluConnect(PChar(Server), Port, PChar(ModChars), nil, Size);
end;

function slConnect(Server: string; Port: Integer; ModChars: string; var OutData: string): Integer;
var
  Size: Integer;
begin
  Size := Length(OutData);
  Result := sluConnect(PChar(Server), Port, PChar(ModChars), PChar(OutData), Size);
  SetLength(OutData, Size);
end;

procedure slDisconnect();
begin
  sluDisconnect;
end;

function slF(ColumnNumber: Integer; SetNumber: Integer): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluF(ColumnNumber, PChar(Result), Size, SetNumber);
  SetLength(Result, Size);
end;

function slFX(ColumnNumber: Integer; ModChars: string; SetNumber: Integer): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluFX(ColumnNumber, PChar(Result), Size, SetNumber, PChar(ModChars));
  SetLength(Result, Size);
end;

function slFN(ColumnName: string; SetNumber: Integer): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluFN(PChar(ColumnName), PChar(Result), Size, SetNumber);
  SetLength(Result, Size);
end;

function slFNX(ColumnName: string; ModChars: string; SetNumber: Integer): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluFNX(PChar(ColumnName), PChar(Result), Size, SetNumber, PChar(ModChars));
  SetLength(Result, Size);
end;

function slGetColumnCount(SetNumber: Integer): Integer;
begin
  Result := sluGetColumnCount(SetNumber);
end;

function slGetColumnName(ColumnNumber: Integer; SetNumber: Integer): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluGetColumnName(ColumnNumber, PChar(Result), Size, SetNumber);
  SetLength(Result, Size);
end;

function slGetError(): string;
var
  Size: Integer;
begin
  Size := BUFFER_LENGTH;
  SetLength(Result, Size);
  sluGetError(PChar(Result), Size);
  SetLength(Result, Size);
end;

function slGetRow(SetNumber: Integer; ModChars: string): Integer;
begin
  Result := sluGetRow(SetNumber, PChar(ModChars));
end;

function  slOpen(FileName: string; ModChars: string): Integer;
begin
  Result := sluOpen(PChar(FileName), PChar(ModChars));
end;

function slSel(Statement: string; SetNumber: Integer; ModChars: string): Integer;
begin
  Result := sluSel(PChar(Statement), SetNumber, PChar(ModChars));
end;

end.
